package com.aizuda.boot.modules.business.performancePlan.entity;

import com.aizuda.boot.modules.common.constant.enums.CycleTypeEnum;
import com.aizuda.boot.modules.common.constant.enums.PaymentIntervalTypeEnum;
import com.aizuda.boot.modules.common.constant.enums.PaymentTimeTypeEnum;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 付款计划实体类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("payment_plan")
@Schema(description = "付款计划实体")
public class PaymentPlanEntity {

    @TableId(type = IdType.AUTO)
    @Schema(description = "主键ID")
    private Integer id;

    @Schema(description = "合同ID")
    @TableField("contract_id")
    private Integer contractId;

    @Schema(description = "是否为周期计划（0=否，1=是）")
    @TableField("is_cycle_plan")
    private Integer isCyclePlan;

    @Schema(description = "付款频率（如按月、季度）")
    @TableField("payment_frequency")
    private Integer paymentFrequency;

    @Schema(description = "周期类型（年、月、周、日）")
    @TableField("cycle_type")
    private CycleTypeEnum cycleType;

    @Schema(description = "首次付款时间")
    @TableField("first_payment_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate firstPaymentDate;

    @Schema(description = "总期数")
    @TableField("total_periods")
    private Integer totalPeriods;

    @Schema(description = "计划组ID")
    @TableField("plan_group_id")
    private Integer planGroupId;

    @Schema(description = "排序")
    private Integer sort;

    @Schema(description = "履约类型（0=不需付款，1=需付款）")
    @TableField("fulfillment_type")
    private Integer fulfillmentType;

    @Schema(description = "履约事项")
    @TableField("fulfillment_item")
    private String fulfillmentItem;

    @Schema(description = "是否需要发票（0=否，1=是）")
    @TableField("need_invoice")
    private Integer needInvoice;

    @Schema(description = "付款时间类型（固定付款日期、无固定日期、履约完成后）")
    @TableField("payment_time_type")
    private PaymentTimeTypeEnum paymentTimeType;

    @Schema(description = "付款时间（若为固定时间类型）")
    @TableField("payment_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate paymentDate;

    @Schema(description = "付款时间间隔（用于周期计划）")
    @TableField("payment_interval")
    private Integer paymentInterval;

    @Schema(description = "付款时间间隔类型（自然日、工作日）")
    @TableField("payment_interval_type")
    private PaymentIntervalTypeEnum paymentIntervalType;

    @Schema(description = "付款金额")
    @TableField("payment_amount")
    private Integer paymentAmount;

    @Schema(description = "货币类型")
    @TableField("currency_type")
    private String currencyType;

    @Schema(description = "交易方ID")
    @TableField("partner_id")
    private Integer partnerId;

    @Schema(description = "付款对象")
    @TableField("payment_receiver")
    private String paymentReceiver;

    @Schema(description = "付款对象详情（JSON数据）")
    @TableField("payment_receiver_info")
    private String paymentReceiverInfo;

    @Schema(description = "银行账号")
    @TableField("bank_account")
    private String bankAccount;

    @Schema(description = "开户行名称")
    @TableField("bank_name")
    private String bankName;

    @Schema(description = "账户名称")
    @TableField("account_name")
    private String accountName;

    @Schema(description = "付款说明")
    @TableField("payment_note")
    private String paymentNote;

    @Schema(description = "自定义字段")
    @TableField("ext_data")
    private String extData;

    @Schema(description = "创建时间")
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
}
